<div id="statistics-modal" class="modal">
    <div class="modal-content">
        <div class="modal-header">
            <h3>检测日志统计分析</h3>
            <span class="close-btn" onclick="closeModal()">&times;</span>
        </div>
        
        <div class="modal-body">
            <!-- 统计类型选择 -->
            <div class="form-section">
                <div class="section-title">统计类型</div>
                <div class="radio-group">
                    <label class="radio-item checked">
                        <input type="radio" id="basic-statistics" name="stats-type" value="basic" checked>
                        <span>基础统计</span>
                    </label>
                    <label class="radio-item">
                        <input type="radio" id="defect-type-statistics" name="stats-type" value="defect_type">
                        <span>缺陷类型统计</span>
                    </label>
                </div>
            </div>

            <!-- 时间范围选择 -->
            <div class="form-section">
                <div class="section-title">时间范围</div>
                <div class="form-row">
                    <div style="flex: 1;">
                        <label for="time-range">选择范围:</label>
                        <select id="time-range" onchange="toggleDateRange()">
                            <option value="latest">最近数据</option>
                            <option value="range">指定日期范围</option>
                        </select>
                    </div>
                </div>

                <!-- 最近数据输入 -->
                <div id="latest-range" class="latest-inputs">
                    <div class="latest-controls">
                        <div class="input-group">
                            <label for="latest-value">数量:</label>
                            <input type="number" id="latest-value" min="1" max="999" value="24">
                        </div>
                        <div class="input-group">
                            <label for="latest-unit">单位:</label>
                            <select id="latest-unit">
                                <option value="hours">小时</option>
                                <option value="days">天</option>
                            </select>
                        </div>
                    </div>
                </div>

                <!-- 日期范围输入 -->
                <div id="date-range" class="hidden">
                    <div class="date-inputs">
                        <div>
                            <label for="start-date">开始日期:</label>
                            <input type="date" id="start-date">
                        </div>
                        <div>
                            <label for="end-date">结束日期:</label>
                            <input type="date" id="end-date">
                        </div>
                    </div>
                </div>
            </div>

            <!-- 重采样频率选择 -->
            <div class="form-section">
                <div class="section-title">重采样频率</div>
                <div class="form-row">
                    <div style="flex: 1;">
                        <label for="resample-freq">时间间隔:</label>
                        <select id="resample-freq">
                            <option value="">不重采样</option>
                            <option value="15T">15分钟</option>
                            <option value="30T">30分钟</option>
                            <option value="1h" selected>1小时</option>
                            <option value="2h">2小时</option>
                            <option value="6h">6小时</option>
                            <option value="12h">12小时</option>
                            <option value="1D">1天</option>
                            <option value="1W">1周</option>
                        </select>
                    </div>
                </div>
                <div class="help-text">
                    重采样将数据按指定时间间隔聚合，便于观察趋势变化
                </div>
            </div>

            <!-- 执行按钮 -->
            <div class="btn-container">
                <button class="btn" onclick="runStatistics(event)">执行统计分析</button>
            </div>

            <!-- 结果显示 -->
            <div class="result-section">
                <div class="result-title">统计结果</div>
                <pre id="statistics-result">点击"执行统计分析"按钮开始分析...</pre>
            </div>
        </div>
    </div>
</div>